package org.jiuling.aliyun.sms.factory;

import com.aliyun.dysmsapi20170525.Client;
import com.aliyun.teaopenapi.models.Config;
import org.jiuling.aliyun.sms.config.AliYunSmsConfig;

/**
 * 阿里云短信同步
 * @author 紫灵
 * @date 2023年03月02日 15时03分29秒
 */
public abstract class AliYunSmsSynchronization {

    /** 阿里云短信配置 */
    private final AliYunSmsConfig aliYunSmsConfig;

    public AliYunSmsSynchronization(AliYunSmsConfig aliYunSmsConfig) {
        this.aliYunSmsConfig = aliYunSmsConfig;
    }

    /**
     * 创建同步客户端客户端
     * @return 客户端
     */
    public Client create() throws Exception {
        Config config = new Config()
                .setAccessKeyId(aliYunSmsConfig.getAliYunConfig().getAccessKeyId())
                .setAccessKeySecret(aliYunSmsConfig.getAliYunConfig().getAccessKeySecret());
        config.endpoint = aliYunSmsConfig.getServiceAccessPoint().getPublicAccessAddress();
        return new Client(config);
    }
}
